<?php
/*
 * Created on 20 mars 2009
 * Created by Ludovic Reenaers
 * lreenaers@hotmail.com
 */
 class Profile{
 	private $id;
 	private $name;
 	private $tokens = Array();
 	private $disabled;
 	function __construct($id) {
 		if (is_int($id)){
 			if($id > 0){
				$this->id=$id;
 			}else{
 				throw new Exception("id must be superior to 0");
 			}
 		}else{
 			throw new Exception("id must be integer");
 		}
	}
	function getDisabled(){
		return $this->disabled;
	}
	function setDisabled($bool){
		if(is_bool($bool)){
			$this->disabled=$bool;
		}else{
			throw new Exception("disabled must be boolean");
		}
	}
	function setName($name){
		if(is_string($name)){
			
			if(str_replace(" ","",$name) != ""){
				if(strlen($name) > 0 and strlen($name) < 11){
					$this->name  =$name;
				}else{
					throw new Exception("name length could be 1 to 10 char");
				}
			}else{
				throw new Exception("name could not be empty string");	
			}
		}else{
			throw new Exception("name must be a string");
		}
	}
	function setTokens($tokensArray){
		if (is_array($tokensArray)){
			$booltok=true;
			foreach($tokensArray as $token){
				if(!is_a($token,"Token")){
					$booltok =false;
				}
			}
			if ($booltok){
				$this->tokens=$tokensArray;
			}else{
				throw new Exception("tokensArray elements must be token");
			}
		}else{
			throw new Exception("tokensArray must be of type Array");
		}
	}
	function getId(){
		return $this->id;
	}
	function getName(){
		return $this->name;
	}
	function getTokens(){
		return $this->tokens;
	}
	function getTokensStringArray(){
		$tmp = Array();
		foreach($this->tokens as $token){
			array_push($tmp,$token->getName());
		}
		return $tmp;
	}
 }
?>
